package com.dream.airinfo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by ZhangPing on 2017/7/27.
 */

public class DBHelper extends SQLiteOpenHelper{
    public DBHelper(Context context) {
        super(context, "AirDB", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table AirInfo(" +
                "_id integer primary key autoincrement," +
                "city text," +
                "aqi integer," +
                "pm2_5 integer," +
                "airDate text)");
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

        db.execSQL("insert into AirInfo values(null,'北京',65,24,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*7)))+"')");
        db.execSQL("insert into AirInfo values(null,'北京',45,34,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*6)))+"')");
        db.execSQL("insert into AirInfo values(null,'北京',34,42,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*5)))+"')");
        db.execSQL("insert into AirInfo values(null,'北京',34,12,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*4)))+"')");
        db.execSQL("insert into AirInfo values(null,'北京',42,35,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*3)))+"')");
        db.execSQL("insert into AirInfo values(null,'北京',30,76,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*2)))+"')");
        db.execSQL("insert into AirInfo values(null,'北京',65,82,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*1)))+"')");

        db.execSQL("insert into AirInfo values(null,'武汉',41,25,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*7)))+"')");
        db.execSQL("insert into AirInfo values(null,'武汉',16,21,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*6)))+"')");
        db.execSQL("insert into AirInfo values(null,'武汉',32,44,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*5)))+"')");
        db.execSQL("insert into AirInfo values(null,'武汉',15,19,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*4)))+"')");
        db.execSQL("insert into AirInfo values(null,'武汉',53,22,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*3)))+"')");
        db.execSQL("insert into AirInfo values(null,'武汉',20,43,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*2)))+"')");
        db.execSQL("insert into AirInfo values(null,'武汉',71,61,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*1)))+"')");

        db.execSQL("insert into AirInfo values(null,'上海',25,25,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*7)))+"')");
        db.execSQL("insert into AirInfo values(null,'上海',32,15,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*6)))+"')");
        db.execSQL("insert into AirInfo values(null,'上海',24,44,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*5)))+"')");
        db.execSQL("insert into AirInfo values(null,'上海',38,59,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*4)))+"')");
        db.execSQL("insert into AirInfo values(null,'上海',55,32,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*3)))+"')");
        db.execSQL("insert into AirInfo values(null,'上海',20,13,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*2)))+"')");
        db.execSQL("insert into AirInfo values(null,'上海',29,71,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*1)))+"')");

        db.execSQL("insert into AirInfo values(null,'深圳',55,25,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*7)))+"')");
        db.execSQL("insert into AirInfo values(null,'深圳',54,74,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*5)))+"')");
        db.execSQL("insert into AirInfo values(null,'深圳',28,39,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*4)))+"')");
        db.execSQL("insert into AirInfo values(null,'深圳',45,72,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*3)))+"')");
        db.execSQL("insert into AirInfo values(null,'深圳',10,43,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*2)))+"')");
        db.execSQL("insert into AirInfo values(null,'深圳',42,61,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*1)))+"')");

        db.execSQL("insert into AirInfo values(null,'重庆',45,45,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*7)))+"')");
        db.execSQL("insert into AirInfo values(null,'重庆',45,35,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*6)))+"')");
        db.execSQL("insert into AirInfo values(null,'重庆',34,64,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*5)))+"')");
        db.execSQL("insert into AirInfo values(null,'重庆',28,49,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*4)))+"')");
        db.execSQL("insert into AirInfo values(null,'重庆',15,72,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*3)))+"')");
        db.execSQL("insert into AirInfo values(null,'重庆',20,33,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*2)))+"')");
        db.execSQL("insert into AirInfo values(null,'重庆',48,51,'"+sdf.format(new Date(System.currentTimeMillis()-(1000*60*60*24*1)))+"')");


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
